import {createRouter, createWebHistory } from 'vue-router'
import BookList from '../components/BookList.vue'
import Header from "@/components/Header.vue";

const routes = [
    {
        path: '/myStorage',
        name: 'MyStorage',
        component: () => import("../components/MyStorage.vue")
    },
    {
        path: '/all',
        name: 'All',
        component: () => import("../components/BookList.vue"),
        props: route => ({ keyword: route.query.keyword }) // 获取查询参数并传递给组件
    },
    {
        path: '/newAddress',
        name: 'NewAddress',
        component: () => import("../components/NewAddress.vue")
    },
    {
        path: '/myOrder',
        name: 'MyOrder',
        component: () => import("../components/MyOrder.vue")
    },
    {
        path: '/getBookType',
        name: 'typeId',
        component: () => import("../components/BookList.vue")
    },
    {
        path: '/shoppingCart',
        name: 'Cart',
        component: () => import("../components/Cart.vue")
    },
    {
        path: '/settlement',
        name: 'Settlement',
        component: () => import("../components/Settlement.vue")
    },
    {
        path: '/',
        name: 'Home',
        component: BookList
    },
    {
        path: '/login',
        name: 'Login',
        component: () => import('../components/views/Login.vue')
    },

    {
        path: '/register',
        name: 'Register',
        component: () => import('../components/views/Register.vue')
    },
    {
        path: '/welcome',
        name: 'Welcome',
        component: () => import('../components/views/Welcome.vue')
    }
]

const router = createRouter({
    history: createWebHistory(),
    routes
})

export default router